from app import db
from flask_login import UserMixin
from datetime import datetime


class User(UserMixin, db.Model):
    id = db.Column(db.String(80), unique=True, nullable=False, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(120), unique=True, nullable=False)
    email = db.Column(db.String(120),  unique=True, nullable=False)

    def is_active(self):
        return True

    def get_id(self):
        return str(self.id)

    def __repr__(self):
        return '<User {}}>'.format(self.username)


class TestRecord(db.Model):
    test_id = db.Column(db.String(255), primary_key=True)
    username = db.Column(db.String(255), nullable=False )
    date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    result = db.Column(db.String(255), nullable=False)
    age = db.Column(db.Integer)
    gender = db.Column(db.Integer)
    bmi = db.Column(db.Float)
    ap_hi = db.Column(db.Float)
    ap_lo = db.Column(db.Float)
    cholesterol = db.Column(db.Float)
    gluc = db.Column(db.Float)
    smoke = db.Column(db.Integer)
    alco = db.Column(db.Integer)
    active = db.Column(db.Integer)

    def __repr__(self):
        return f'<TestRecord {self.test_id}>'
